package cn.edu.fudan.tools;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import cn.edu.fudan.type.Config;

public class GetConfig {
	
	public Config getConfig() throws IOException{
		Config config = new Config();
		
		String relativelyPath=System.getProperty("user.dir");
		
		Properties props = new Properties();
	    
		InputStream in = new FileInputStream(relativelyPath+"/src/main/resources/config.properties");
		
		props.load(in);
	    in.close();
	    
	    String path = props.getProperty("data.path");
	    config.setPath(path);
	    int N_segment = Integer.parseInt(props.getProperty("N_segment"));
	    config.setN_segment(N_segment);
	    long threshold_window = Long.parseLong(props.getProperty("threshold_window"));
	    config.setThreshold_window(threshold_window);
	    double probability = Double.parseDouble(props.getProperty("probability"));
	    config.setProbability(probability);
	    long interval = Long.parseLong(props.getProperty("interval"));
	    config.setInterval(interval);
	    long window_length = Long.parseLong(props.getProperty("window_length"));
	    config.setWindow_length(window_length);
	    int K = Integer.parseInt(props.getProperty("K"));
	    config.setK(K);
	    
	    return config;
	}

}
